import React from 'react'
import { Typography } from 'antd'
import { TextWidget, getMessage } from '@inbiz/react';
import './style.less'
export default function FormItemTitle(props) {
  const { title, form, type, showClear, clearField, config } = props
  // 有clearField就不用type和form了
  const clearForm = () => {
    if (clearField) {
      clearField()
    } else {
      form.resetFields([type])
    }
  }
  return (
    <div className='itemTitle'>
      <Typography.Text ellipsis style={{ width: config.sectionWidth || config.rightSectionWidth - 75, fontSize: 14 }} title={getMessage(title)}>{getMessage(title)}： </Typography.Text>
      {showClear && <div className='clear' onClick={clearForm}><TextWidget>SearchResultEngine.clear</TextWidget></div>}
    </div>
  )
}
